package Function;

public class Function2 extends Function{
	private double ymax;
	private double ymin;
	
	private int xLength;
	private int yLength;

	public Function2(){
		// x e [-3.0,12.1]
		xmin = -3.0;
		xmax = 12.1;
		
		// y e [4.1,5.8]
		ymin = 4.1;
		ymax = 5.8;
	}
	
	public int bitLength(double accuracy){
		// length for x
		xLength = super.bitLength(accuracy);
		yLength = (int) log2(1 + ((ymax-ymin)/accuracy));
		return xLength + yLength;
	}
	
	public double evaluate(double[] parameters) {
		// f(x,y) = 21.5 + x.sen(4pi x)+y.sen(20pi y)
		double x = parameters[0] * Math.sin(4*Math.PI*parameters[0]);
		double y = parameters[1] * Math.sin(20*Math.PI*parameters[1]);
		return 21.5 + x + y;
	}

	// Getters and Setters
	public void setYmax(double ymax) { this.ymax = ymax; }
	public double getYmax() { return ymax; }
	public void setYmin(double ymin) { this.ymin = ymin; }
	public double getYmin() { return ymin; }
	public int getxLength() { return xLength; }
	public int getyLength() { return yLength; }
}
